class Animal {
    public void eat() {
        System.out.println("动物吃东西");
    }
}

class Dog extends Animal {
    @Override
    public void eat() {
        System.out.println("狗吃骨头");
    }

    public void lookHome() {
        System.out.println("狗看家");
    }
}

class Cat extends Animal {
    @Override
    public void eat() {
        System.out.println("猫吃鱼");
    }

    public void catchMouse() {
        System.out.println("猫抓老鼠");
    }
}

public class Work04 {
    public static void main(String[] args) {
        Animal a = new Dog();
        a.eat();
        // 正确调用子类特有方法的方式
        if (a instanceof Dog) {
            Dog dog = (Dog) a;
            dog.lookHome(); // 输出：狗看家
        }

        Animal a2 = new Cat();
        a2.eat(); // 输出：猫吃鱼

        if (a2 instanceof Cat) {
            Cat cat = (Cat) a2;
            cat.catchMouse(); // 输出：猫抓老鼠
        }
    }
}